package health_system.health_system.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.view.RedirectView;

/**
 * Controller for handling API path redirections to view pages
 * Allows users to enter API paths in browser URL and be redirected to the appropriate view
 */
@Controller
@RequestMapping("/api")
public class ApiPageRedirectController {

    /**
     * Redirect API auth login path to the login page
     * 
     * @return redirect to login page
     */
    @GetMapping("/auth/login")
    public RedirectView redirectApiAuthLogin() {
        // 使用RedirectView而不是ModelAndView，确保重定向更可靠
        return new RedirectView("/auth/login", true);
    }
    @GetMapping("/login")
    public RedirectView redirectApiAuthLogin1() {
        // 使用RedirectView而不是ModelAndView，确保重定向更可靠
        return new RedirectView("/auth/login", true);
    }
    
    /**
     * Redirect API auth register path to the registration page
     * 
     * @return redirect to registration page
     */
    @GetMapping("/auth/register")
    public RedirectView redirectApiAuthRegister() {
        return new RedirectView("/auth/register", true);
    }
    
    /**
     * Redirect API users register path to the registration page
     * 
     * @return redirect to registration page
     */
    @GetMapping("/users/register")
    public RedirectView redirectApiUsersRegister() {
        return new RedirectView("/auth/register", true);
    }
} 